package com.xnyzc.lhy.order.service.impl.order;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xnyzc.lhy.common.exception.PangException;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.common.penum.order.ECostDetailsName;
import com.xnyzc.lhy.common.penum.order.EGetCostDetailsName;
import com.xnyzc.lhy.common.penum.order.EOrderNoType;
import com.xnyzc.lhy.common.penum.order.EOrderOtherPrice;
import com.xnyzc.lhy.common.penum.order.EOrderStatus;
import com.xnyzc.lhy.common.penum.star.EStarType;
import com.xnyzc.lhy.common.util.CheckUtil;
import com.xnyzc.lhy.common.util.ResultListUtil;
import com.xnyzc.lhy.order.entity.comment.OaSysComment;
import com.xnyzc.lhy.order.entity.common.order.OrderCommon;
import com.xnyzc.lhy.order.entity.order.OaCOrder;
import com.xnyzc.lhy.order.entity.order.OaCOrderApprovalOfficial;
import com.xnyzc.lhy.order.entity.order.OaCOrderDeptOfficial;
import com.xnyzc.lhy.order.entity.order.OaCOrderPersonal;
import com.xnyzc.lhy.order.entity.order.OaCOrderPersonalOfficial;
import com.xnyzc.lhy.order.entity.order.OaDOrder;
import com.xnyzc.lhy.order.entity.order.OaOrderEvaluation;
import com.xnyzc.lhy.order.entity.order.OaOrderOtherPrice;
import com.xnyzc.lhy.order.entity.system.OaSysGlobalConfig;
import com.xnyzc.lhy.order.entity.user.OaCUser;
import com.xnyzc.lhy.order.mapper.comment.OaSysCommentMapper;
import com.xnyzc.lhy.order.mapper.order.OaCOrderApprovalOfficialMapper;
import com.xnyzc.lhy.order.mapper.order.OaCOrderDeptOfficialMapper;
import com.xnyzc.lhy.order.mapper.order.OaCOrderPersonalMapper;
import com.xnyzc.lhy.order.mapper.order.OaCOrderPersonalOfficialMapper;
import com.xnyzc.lhy.order.mapper.order.OaDOrderMapper;
import com.xnyzc.lhy.order.mapper.order.OaOrderEvaluationMapper;
import com.xnyzc.lhy.order.mapper.order.OaOrderOtherPriceMapper;
import com.xnyzc.lhy.order.mapper.system.OaSysGlobalConfigMapper;
import com.xnyzc.lhy.order.mapper.user.OaCUserMapper;
import com.xnyzc.lhy.order.service.comment.IOaSysCommentService;
import com.xnyzc.lhy.order.service.order.IOaCOrderDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description 订单详情
 * @Author zhuyubin
 * @Date 2019/8/15 17:34
 **/
@Service
public class OaCOrderDetailsServiceImpl implements IOaCOrderDetailsService {

    private static final String ZERO = "0.00";

    @Autowired
    private OaCUserMapper oaCUserMapper;
    @Autowired
    private OaSysCommentMapper oaSysCommentMapper;
    @Autowired
    private OaOrderEvaluationMapper oaOrderEvaluationMapper;
    @Autowired
    private OaCOrderPersonalMapper oaCOrderPersonalMapper;
    @Autowired
    private OaCOrderPersonalOfficialMapper oaCOrderPersonalOfficialMapper;
    @Autowired
    private OaCOrderDeptOfficialMapper oaCOrderDeptOfficialMapper;
    @Autowired
    private OaCOrderApprovalOfficialMapper oaCOrderApprovalOfficialMapper;
    @Autowired
    private IOaSysCommentService iOaSysCommentService;
    @Autowired
    private OrderCommon orderCommon;
    @Autowired
    private OaDOrderMapper oaDOrderMapper;
    @Autowired
    private OaOrderOtherPriceMapper oaOrderOtherPriceMapper;
    @Autowired
    private OaSysGlobalConfigMapper oaSysGlobalConfigMapper;

    /**
     * 司机订单详情*
     * @param driverId 用户id
     * @param tag 租户
     * @param userType 用户类型
     * @param orderNo 订单号
     * @return
     */
    @Override
    public Map<String, Object> getOrderDetails(Long driverId, String tag, String userType, String orderNo){
        OaCOrder oaCOrder = orderCommon.selectOn(orderNo);
        if (CheckUtil.objIsEmpty(oaCOrder)){
            throw PangException.create(EErrorCode.unOrderNo);
        }
        Map<String, Object> result = this.initGetOrderDetails();
        // 获取用户信息
        Long userId = oaCOrder.getUserId();
        OaCUser oaCUser = oaCUserMapper.selectById(oaCOrder.getUserId());
        if (CheckUtil.objIsEmpty(oaCUser)){
            throw PangException.create(EErrorCode.authIdentityErr);
        }
        String phone = oaCUser.getUserPhone().substring(7);
        result.put("phone", phone);
        result.put("orderStatusMsg", EOrderStatus.findById(oaCOrder.getOrderStatus()).getValue());
        result.put("orderStatusCode", EOrderStatus.findById(oaCOrder.getOrderStatus()).getType());
        result.put("starMsg", "");
        // 司机订单
        OaDOrder oaDOrder = oaDOrderMapper.selectOne(
                Wrappers.<OaDOrder>lambdaQuery()
                        .eq(OaDOrder::getDriverId, driverId)
                        .eq(OaDOrder::getTag, tag)
                        .eq(OaDOrder::getOrderNo, orderNo
        ));
        // 自费叫车
        if (orderNo.contains(EOrderNoType.ZFJC.getType())){
            // 查订单
            OaCOrderPersonal oaCOrderPersonal = oaCOrderPersonalMapper.selectOne(
                    Wrappers.<OaCOrderPersonal>lambdaQuery()
                            .eq(OaCOrder::getDriverId, driverId)
                            .eq(OaCOrder::getTag, tag)
                            .eq(OaCOrder::getOrderNo, orderNo)
            );
            if (CheckUtil.objIsEmpty(oaCOrderPersonal)){
                throw PangException.create(EErrorCode.unOrder);
            }
            result.put("isPay", CheckUtil.objIsNotEmpty(oaCOrderPersonal.getPaymentType()));
            result.put("startAddress", this.isNullStr(oaCOrderPersonal.getStartAddress()));
            result.put("endAddress", this.isNullStr(oaCOrderPersonal.getEndAddress()));
            result.put("money", CheckUtil.objIsEmpty(oaCOrderPersonal.getDrawFee()) ? "" : oaCOrderPersonal.getDrawFee().toString());
            return this.getComment(oaDOrder, driverId, userType, tag, orderNo, result);
        }
        // 个人公务
        else if (orderNo.contains(EOrderNoType.GRGW.getType())){
            OaCOrderPersonalOfficial oaCOrderPersonalOfficial = oaCOrderPersonalOfficialMapper.selectOne(
                    Wrappers.<OaCOrderPersonalOfficial>lambdaQuery()
                            .eq(OaCOrder::getUserId, userId)
                            .eq(OaCOrder::getTag, tag)
                            .eq(OaCOrder::getOrderNo, orderNo)
            );
            if (CheckUtil.objIsEmpty(oaCOrderPersonalOfficial)){
                throw PangException.create(EErrorCode.unOrder);
            }
            result.put("money", CheckUtil.objIsEmpty(oaCOrderPersonalOfficial.getDrawFee()) ? "" : oaCOrderPersonalOfficial.getDrawFee().toString());
            result.put("endAddress", this.isNullStr(oaCOrderPersonalOfficial.getEndAddress()));
            result.put("startAddress", this.isNullStr(oaCOrderPersonalOfficial.getStartAddress()));
            result.put("isPay", CheckUtil.objIsNotEmpty(oaCOrderPersonalOfficial.getPaymentType()));
            return this.getComment(oaDOrder, driverId, userType, tag, orderNo, result);

        }
        // 部门公务
        else if (orderNo.contains(EOrderNoType.BMGW.getType())){
            OaCOrderDeptOfficial oaCOrderDeptOfficial = oaCOrderDeptOfficialMapper.selectOne(
                    Wrappers.<OaCOrderDeptOfficial>lambdaQuery()
                            .eq(OaCOrder::getUserId, userId)
                            .eq(OaCOrder::getTag, tag)
                            .eq(OaCOrder::getOrderNo, orderNo)
            );
            if (CheckUtil.objIsEmpty(oaCOrderDeptOfficial)){
                throw PangException.create(EErrorCode.unOrder);
            }
            result.put("startAddress", this.isNullStr(oaCOrderDeptOfficial.getStartAddress()));
            result.put("endAddress", this.isNullStr(oaCOrderDeptOfficial.getEndAddress()));
            result.put("money", CheckUtil.objIsEmpty(oaCOrderDeptOfficial.getDrawFee()) ? "" : oaCOrderDeptOfficial.getDrawFee().toString());
            result.put("isPay", CheckUtil.objIsNotEmpty(oaCOrderDeptOfficial.getPaymentType()));
            return this.getComment(oaDOrder, driverId, userType, tag, orderNo, result);
        }
        // 审批公务
        else if (orderNo.contains(EOrderNoType.SPGW.getType())){
            OaCOrderApprovalOfficial oaCOrderApprovalOfficial = oaCOrderApprovalOfficialMapper.selectOne(
                    Wrappers.<OaCOrderApprovalOfficial>lambdaQuery()
                            .eq(OaCOrderApprovalOfficial::getUserId, userId)
                            .eq(OaCOrderApprovalOfficial::getTag, tag)
                            .eq(OaCOrderApprovalOfficial::getOrderNo, orderNo)
            );
            if (CheckUtil.objIsEmpty(oaCOrderApprovalOfficial)){
                throw PangException.create(EErrorCode.unOrder);
            }
            result.put("money", CheckUtil.objIsEmpty(oaCOrderApprovalOfficial.getDrawFee()) ? "" : oaCOrderApprovalOfficial.getDrawFee().toString());
            result.put("isPay", CheckUtil.objIsNotEmpty(oaCOrderApprovalOfficial.getPaymentType()));
            result.put("startAddress", this.isNullStr(oaCOrderApprovalOfficial.getStartAddress()));
            result.put("endAddress", this.isNullStr(oaCOrderApprovalOfficial.getEndAddress()));
            return this.getComment(oaDOrder, driverId, userType, tag, orderNo, result);
        }
        // 非法订单号
        else {
            throw PangException.create(EErrorCode.unOrderNo);
        }
    }

    /**
     * 订单详情费用明细
     * @param userId 用户id
     * @param tag 租户
     * @param orderNo 订单号
     * @return
     */
    @Override
    public Map<String, Object> getCostDetails(Long userId, String tag, String orderNo){
        Map<String, Object> result = new HashMap<>(16);
        result.put("title", "");
        result.put("money", "");
        result.put("list", new ArrayList<>());
        result.put("prompt", "");
        OaSysGlobalConfig oaSysGlobalConfig = oaSysGlobalConfigMapper.selectOne(Wrappers.<OaSysGlobalConfig>lambdaQuery().eq(OaSysGlobalConfig::getTag, tag));
        if (CheckUtil.objIsNotEmpty(oaSysGlobalConfig)){
            result.put("prompt", oaSysGlobalConfig.getPayDetailPrompt());
        }
        if (orderNo.contains(EOrderNoType.ZFJC.getType())){
            OaCOrderPersonal oaCOrderPersonal = oaCOrderPersonalMapper.selectOne(
                    Wrappers.<OaCOrderPersonal>lambdaQuery()
                            .eq(OaCOrder::getDriverId, userId)
                            .eq(OaCOrder::getTag, tag)
                            .eq(OaCOrder::getOrderNo, orderNo)
            );
            this.isUnOrder(oaCOrderPersonal);
            return this.getZFJC(tag, oaCOrderPersonal, result);
        }
        // 个人公务
        else if (orderNo.contains(EOrderNoType.GRGW.getType())){
            OaCOrderPersonalOfficial oaCOrderPersonalOfficial = oaCOrderPersonalOfficialMapper.selectOne(
                    Wrappers.<OaCOrderPersonalOfficial>lambdaQuery()
                            .eq(OaCOrder::getTag, tag)
                            .eq(OaCOrder::getDriverId, userId)
                            .eq(OaCOrder::getOrderNo, orderNo)
            );
            this.isUnOrder(oaCOrderPersonalOfficial);
            return this.getGRGW(tag, oaCOrderPersonalOfficial, result);
        }
        // 部门公务
        else if (orderNo.contains(EOrderNoType.BMGW.getType())){
            OaCOrderDeptOfficial oaCOrderDeptOfficial = oaCOrderDeptOfficialMapper.selectOne(
                    Wrappers.<OaCOrderDeptOfficial>lambdaQuery()
                            .eq(OaCOrder::getDriverId, userId)
                            .eq(OaCOrder::getOrderNo, orderNo)
                            .eq(OaCOrder::getTag, tag)
            );
            this.isUnOrder(oaCOrderDeptOfficial);
            return this.getBMGW(tag, oaCOrderDeptOfficial, result);
        }
        // 审批公务
        else if (orderNo.contains(EOrderNoType.SPGW.getType())){
            OaCOrderApprovalOfficial oaCOrderApprovalOfficial = oaCOrderApprovalOfficialMapper.selectOne(
                    Wrappers.<OaCOrderApprovalOfficial>lambdaQuery()
                            .eq(OaCOrderApprovalOfficial::getOrderNo, orderNo)
                            .eq(OaCOrderApprovalOfficial::getDriverId, userId)
                            .eq(OaCOrderApprovalOfficial::getTag, tag)
            );
            this.isUnOrder(oaCOrderApprovalOfficial);
            return this.getSPGW(tag, oaCOrderApprovalOfficial, result);
        }
        // 非法订单号
        else {
            throw PangException.create(EErrorCode.unOrderNo);
        }
    }

    /**
     * 封装自费叫车
     * @param oaCOrderPersonal 自费叫车订单实体
     * @param result 出参
     * @return
     */
    private Map<String, Object> getZFJC(String tag, OaCOrderPersonal oaCOrderPersonal, Map<String, Object> result){
        result.put("title", EOrderNoType.ZFJC.getDesc());
        result.put("money", CheckUtil.objIsEmpty(oaCOrderPersonal.getDrawFee()) ? "" : oaCOrderPersonal.getDrawFee().toString());
        ResultListUtil resultListUtil = new ResultListUtil();
        // 基础费
        BigDecimal baseFee = oaCOrderPersonal.getBaseFee();
        if (CheckUtil.objIsNotEmpty(baseFee)){
            resultListUtil.add(ECostDetailsName.baseFee.getName(), String.format("%s%s", baseFee, ECostDetailsName.yuan.getName()));
        }
        // 总里程
        //Integer milageDistance = oaCOrderPersonal.getMilageDistance().intValue();
        // 里程费
        BigDecimal mileageFee = oaCOrderPersonal.getMileageFee();
        if (CheckUtil.objIsNotEmpty(mileageFee)){
            resultListUtil.add(ECostDetailsName.totalMileageFee.getName(),
                    String.format("%s%s", mileageFee, ECostDetailsName.yuan.getName())
            );
        }
        // 总时长
        //BigDecimal durationTime = oaCOrderPersonal.getDurationTime();
        // 总时长费
        BigDecimal durationFee = oaCOrderPersonal.getDurationFee();
        if (CheckUtil.objIsNotEmpty(durationFee)){
            resultListUtil.add(ECostDetailsName.totalTimeFee.getName(),
                    String.format("%s%s", durationFee, ECostDetailsName.yuan.getName()));
        }
        /*// 远途费
        BigDecimal distanceFee = oaCOrderPersonal.getDistanceFee();
        if (CheckUtil.objIsNotEmpty(distanceFee)){
            resultListUtil.add(
                    ECostDetailsName.longDistanceFee.getName(),
                    String.format("%s%s", distanceFee, ECostDetailsName.yuan.getName())
            );
        }
        // 其他费用
        resultListUtil = this.otherFee(oaCOrderPersonal.getOrderNo(), oaCOrderPersonal.getAwaitFee(), oaCOrderPersonal.getServiceFee(), oaCOrderPersonal.getEmptyDrivingFee(), resultListUtil, tag);*/
        result.put("list", resultListUtil.getList());
        return result;
    }

    /**
     * 封装个人公务
     * @param oaCOrderPersonalOfficial 个人公务订单实体
     * @param result 出参
     * @return
     */
    private Map<String, Object> getGRGW(String tag, OaCOrderPersonalOfficial oaCOrderPersonalOfficial, Map<String, Object> result){
        result.put("title", EOrderNoType.GRGW.getDesc());
        ResultListUtil resultListUtil = new ResultListUtil();
        result.put("money", CheckUtil.objIsEmpty(oaCOrderPersonalOfficial.getDrawFee()) ? "" : oaCOrderPersonalOfficial.getDrawFee().toString());
        // 基础费
        BigDecimal baseFee = oaCOrderPersonalOfficial.getBaseFee();
        if (CheckUtil.objIsNotEmpty(baseFee)){
            resultListUtil.add(ECostDetailsName.baseFee.getName(), String.format("%s%s", baseFee, ECostDetailsName.yuan.getName()));
        }
        // 里程费
        BigDecimal mileageFee = oaCOrderPersonalOfficial.getMileageFee();
        // 总里程
        //Integer milageDistance = oaCOrderPersonalOfficial.getMilageDistance().intValue();
        if (CheckUtil.objIsNotEmpty(mileageFee)){
            resultListUtil.add(ECostDetailsName.totalMileageFee.getName(),
                    String.format("%s%s", mileageFee, ECostDetailsName.yuan.getName())
            );
        }
        // 总时长费
        BigDecimal durationFee = oaCOrderPersonalOfficial.getDurationFee();
        // 总时长
        //BigDecimal durationTime = oaCOrderPersonalOfficial.getDurationTime();
        if (CheckUtil.objIsNotEmpty(durationFee)){
            resultListUtil.add(ECostDetailsName.totalTimeFee.getName(),
                    String.format("%s%s", durationFee, ECostDetailsName.yuan.getName())
            );
        }
        /*// 远途费
        BigDecimal distanceFee = oaCOrderPersonalOfficial.getDistanceFee();
        if (CheckUtil.objIsNotEmpty(distanceFee)){
            resultListUtil.add(
                    ECostDetailsName.longDistanceFee.getName(),
                    String.format("%s%s", distanceFee, ECostDetailsName.yuan.getName())
            );
        }
        // 其他费用
        resultListUtil = this.otherFee(oaCOrderPersonalOfficial.getOrderNo(), oaCOrderPersonalOfficial.getAwaitFee(), oaCOrderPersonalOfficial.getServiceFee(), oaCOrderPersonalOfficial.getEmptyDrivingFee(), resultListUtil, tag);*/
        result.put("list", resultListUtil.getList());
        return result;
    }

    /**
     * 封装部门公务
     * @param oaCOrderDeptOfficial 部门公务订单实体
     * @param result 出参
     * @return
     */
    private Map<String, Object> getBMGW(String tag, OaCOrderDeptOfficial oaCOrderDeptOfficial, Map<String, Object> result){
        ResultListUtil resultListUtil = new ResultListUtil();
        result.put("money", CheckUtil.objIsEmpty(oaCOrderDeptOfficial.getDrawFee()) ? "" : oaCOrderDeptOfficial.getDrawFee().toString());
        result.put("title", EOrderNoType.BMGW.getDesc());
        // 基础费
        BigDecimal baseFee = oaCOrderDeptOfficial.getBaseFee();
        if (CheckUtil.objIsNotEmpty(baseFee)){
            resultListUtil.add(ECostDetailsName.baseFee.getName(), String.format("%s%s", baseFee, ECostDetailsName.yuan.getName()));
        }
        // 里程费
        BigDecimal mileageFee = oaCOrderDeptOfficial.getMileageFee();
        // 总里程
        //Integer milageDistance = oaCOrderDeptOfficial.getMilageDistance().intValue();
        if (CheckUtil.objIsNotEmpty(mileageFee)){
            resultListUtil.add(ECostDetailsName.totalMileageFee.getName(),
                    String.format("%s%s", mileageFee, ECostDetailsName.yuan.getName())
            );
        }
        // 总时长
        //BigDecimal durationTime = oaCOrderDeptOfficial.getDurationTime();
        // 总时长费
        BigDecimal durationFee = oaCOrderDeptOfficial.getDurationFee();
        if (CheckUtil.objIsNotEmpty(durationFee)){
            resultListUtil.add(ECostDetailsName.totalTimeFee.getName(),
                    String.format("%s%s", durationFee, ECostDetailsName.yuan.getName())
            );
        }
        /*// 远途费
        BigDecimal distanceFee = oaCOrderDeptOfficial.getDistanceFee();
        if (CheckUtil.objIsNotEmpty(distanceFee)){
            resultListUtil.add(
                    ECostDetailsName.longDistanceFee.getName(),
                    String.format("%s%s", distanceFee, ECostDetailsName.yuan.getName())
            );
        }
        resultListUtil = this.otherFee(oaCOrderDeptOfficial.getOrderNo(), oaCOrderDeptOfficial.getAwaitFee(), oaCOrderDeptOfficial.getServiceFee(), oaCOrderDeptOfficial.getEmptyDrivingFee(), resultListUtil, tag);*/
        result.put("list", resultListUtil.getList());
        return result;
    }

    /**
     * 封装审批公务
     * @param oaCOrderApprovalOfficial 审批公务订单实体
     * @param result 出参
     * @return
     */
    private Map<String, Object> getSPGW(String tag, OaCOrderApprovalOfficial oaCOrderApprovalOfficial, Map<String, Object> result){
        ResultListUtil resultListUtil = new ResultListUtil();
        result.put("title", EOrderNoType.SPGW.getDesc());
        result.put("money", CheckUtil.objIsEmpty(oaCOrderApprovalOfficial.getDrawFee()) ? "" : oaCOrderApprovalOfficial.getDrawFee().toString());
        // 基础费
        BigDecimal baseFee = oaCOrderApprovalOfficial.getBaseFee();
        if (CheckUtil.objIsNotEmpty(baseFee)){
            resultListUtil.add(ECostDetailsName.baseFee.getName(), String.format("%s%s", baseFee, ECostDetailsName.yuan.getName()));
        }
        // 总里程
        //BigDecimal milageDistance = oaCOrderApprovalOfficial.getMilageDistance();
        // 里程费
        BigDecimal mileageFee = oaCOrderApprovalOfficial.getMileageFee();
        if (CheckUtil.objIsNotEmpty(mileageFee)){
            resultListUtil.add(ECostDetailsName.totalMileageFee.getName(),
                    String.format("%s%s", mileageFee, ECostDetailsName.yuan.getName())
            );
        }
        // 总时长费
        BigDecimal durationFee = oaCOrderApprovalOfficial.getDurationFee();
        // 总时长
        //BigDecimal durationTime = oaCOrderApprovalOfficial.getDurationTime();
        if (CheckUtil.objIsNotEmpty(durationFee)){
            resultListUtil.add(ECostDetailsName.totalTimeFee.getName(),
                    String.format("%s%s", durationFee, ECostDetailsName.yuan.getName())
            );
        }
        /*// 远途费
        BigDecimal distanceFee = oaCOrderApprovalOfficial.getDistanceFee();
        if (CheckUtil.objIsNotEmpty(distanceFee)){
            resultListUtil.add(
                    ECostDetailsName.longDistanceFee.getName(),
                    String.format("%s%s", distanceFee, ECostDetailsName.yuan.getName())
            );
        }
        // 其他费用
        resultListUtil = this.otherFee(oaCOrderApprovalOfficial.getOrderNo(), oaCOrderApprovalOfficial.getAwaitFee(), oaCOrderApprovalOfficial.getServiceFee(), oaCOrderApprovalOfficial.getEmptyDrivingFee(), resultListUtil, tag);*/
        result.put("list", resultListUtil.getList());
        return result;
    }

    /**
     * 实体是否时空
     */
    private void isUnOrder(Object value){
        if (CheckUtil.objIsEmpty(value)){
            throw PangException.create(EErrorCode.unOrder);
        }
    }

    /**
     * 初始化出参
     * @return
     */
    private Map<String, Object> initGetOrderDetails(){
        Map<String, Object> result = new HashMap<>(16);
        result.put("money", "");
        result.put("phone", "");
        result.put("isPay", false);
        result.put("startAddress", "");
        result.put("endAddress", "");
        result.put("isComment", false);
        result.put("star", -1);
        result.put("starList", new ArrayList<>());
        return result;
    }

    /**
     * 查评价
     * @param driverId
     * @param userType
     * @param tag
     * @param orderNo
     * @param result
     * @return
     */
    private Map<String, Object> getComment(OaDOrder oaDOrder, Long driverId, String userType, String tag, String orderNo, Map<String, Object> result){
        if (CheckUtil.objIsNotEmpty(oaDOrder)){
            Integer isComment = oaDOrder.getIsComment();
            // 评价了
            if (CheckUtil.objIsNotEmpty(isComment) && oaDOrder.getIsComment().equals(1)){
                result.put("isComment", true);
                List<OaOrderEvaluation> oaOrderEvaluations = oaOrderEvaluationMapper.selectList(
                        Wrappers.<OaOrderEvaluation>lambdaQuery()
                                .eq(OaOrderEvaluation::getUserId, driverId)
                                .eq(OaOrderEvaluation::getUserType, userType)
                                .eq(OaOrderEvaluation::getTag, tag)
                                .eq(OaOrderEvaluation::getOrderNo, orderNo)
                                .orderByDesc(OaOrderEvaluation::getCreateTime)
                );
                if (CheckUtil.objIsNotEmpty(oaOrderEvaluations)){
                    OaOrderEvaluation oaOrderEvaluation = oaOrderEvaluations.get(0);
                    String tagCommentContent = oaOrderEvaluation.getTagCommentContent();
                    if (CheckUtil.objIsNotEmpty(tagCommentContent)){
                        if (tagCommentContent.indexOf(',') != -1){
                            tagCommentContent = tagCommentContent.split(",")[0];
                        }
                        OaSysComment oaSysComment = oaSysCommentMapper.selectById(tagCommentContent);
                        if (CheckUtil.objIsNotEmpty(oaSysComment)){
                            Integer commentType = oaSysComment.getCommentType();
                            result.put("star", commentType + 1);
                            result.put("starMsg", EStarType.findById(oaSysComment.getCommentType()).getValue());
                        }
                    }
                }
            } else {
                result.put("starList", iOaSysCommentService.getComment(userType, tag));
            }
        }
        return result;
    }

    /**
     * 空处理
     * @param value
     * @return
     */
    private String isNullStr(String value){
        return CheckUtil.objIsEmpty(value) ? "" : value;
    }

    /**
     * 判断是否是空或0
     * @param value
     * @return
     */
    private boolean isNotNull(Object value){
        return !(CheckUtil.objIsEmpty(value) || value.toString().equals(ZERO));
    }

    /**
     * 处理小数空
     * @param bigDecimal 数据
     * @return
     */
    private BigDecimal bigDecimalIsNull(BigDecimal bigDecimal){
        return CheckUtil.objIsEmpty(bigDecimal) ? new BigDecimal("0") : bigDecimal;
    }

    /**
     * 计算其他费用
     * @param orderNo
     * @param awaitFee
     * @param serviceFee
     * @param emptyDrivingFee
     * @param resultListUtil
     * @param tag
     * @return
     */
    private ResultListUtil otherFee(String orderNo, BigDecimal awaitFee, BigDecimal serviceFee, BigDecimal emptyDrivingFee, ResultListUtil resultListUtil, String tag){
        List<OaOrderOtherPrice> oaOrderOtherPrices = oaOrderOtherPriceMapper.selectList(Wrappers.<OaOrderOtherPrice>lambdaQuery().eq(OaOrderOtherPrice::getTag, tag).eq(OaOrderOtherPrice::getOrderNo, orderNo));
        // 其他费用
        if (CheckUtil.objIsNotEmpty(oaOrderOtherPrices)){
            BigDecimal otherMoney = new BigDecimal("0");
            for (OaOrderOtherPrice oaOrderOtherPrice : oaOrderOtherPrices) {
                otherMoney = otherMoney.add(oaOrderOtherPrice.getCostAmount());
            }
            otherMoney = otherMoney.add(this.bigDecimalIsNull(awaitFee)).add(this.bigDecimalIsNull(serviceFee)).add(this.bigDecimalIsNull(emptyDrivingFee));
            if (this.isNotNull(otherMoney)){
                resultListUtil.add(EGetCostDetailsName.otherMoney.getName(), String.format("%s%s", otherMoney, EGetCostDetailsName.yuan.getName()));
            }
            for (OaOrderOtherPrice oaOrderOtherPrice : oaOrderOtherPrices) {
                if (this.isNotNull(otherMoney)){
                    resultListUtil.add(EOrderOtherPrice.findById(oaOrderOtherPrice.getCostType()).getValue(), String.format("%s%s", oaOrderOtherPrice.getCostAmount(), EGetCostDetailsName.yuan.getName()));
                }
            }
            if (this.isNotNull(awaitFee)){
                resultListUtil.add(EGetCostDetailsName.awaitFee.getName(), String.format("%s%s", awaitFee, EGetCostDetailsName.yuan.getName()));
            }
            if (this.isNotNull(serviceFee)){
                resultListUtil.add(EGetCostDetailsName.serviceFee.getName(), String.format("%s%s", serviceFee, EGetCostDetailsName.yuan.getName()));
            }
            if (this.isNotNull(emptyDrivingFee)){
                resultListUtil.add(EGetCostDetailsName.emptyDrivingFee.getName(), String.format("%s%s", emptyDrivingFee, EGetCostDetailsName.yuan.getName()));
            }
        }
        return resultListUtil;
    }
}
